#ifndef __DMX512_A_H
#define __DMX512_A_H
#include "sys.h"


#define UART1_IDLE			0
#define UART1_REC				1
#define UART1_REC_OK		2


#define SEND_DATA_END		3
#define SEND_COMMAND		4
#define SEND_COMM_END		5

#define SEND_IDLE_STATE	0
#define DATA_GEN_STATE	1
#define SEND_DATA_STATE	2
#define WAIT_CMD_STATE	3
#define SEND_CMD_STATE	5
#define REC_ACK_STATE		7
#define SEND_DATA_ONLY	8
#define SEND_ADDR_STATE	9
#define SEND_CYCLE_STATE	10

//extern	u8		send_buf[2048];
//extern	u8    rec_ok_b;
//extern  u8		rec_buf_b[256];
extern	u8  DMX_CLR;
//extern	u8	send_state;
//extern	u8	send_buf_a[1024];
extern  u8		uart1_rec_buf[1024];
extern u16 uart1_rec_cnt ;
extern	u8	dis_buf[1028];
extern  u8	dis_buf_b[1028];
extern	u8	dis_on;
extern  u8	send_cmd_mode;
extern	u8	set_addr_mode;
extern  u16	w_addr;
extern  u16	w_inc;
extern  u16	w_cnt;
extern  u16    all_brightness;
extern	u8    color_brightness[4];
extern  u16	tube_num, err_num;
extern	u16 num;
extern	u8  cycle_check;
extern  u8	conv_serial_start;

extern	u16	bright_data;
extern	u8	gamma_data;
extern	u8	l_adjust_data;

extern	void Dmx_Port_Start(void);
extern  void proc_command_down(void);
extern  void dis_proc_sd(u32 dis_addr);
extern  void dis_proc_test(void);
extern  u16 get_frame_max(u8 ppp);
extern	void send_ucs_addr_start(void);
extern	void dmx_packet_send(void);
extern	void uart1_timeout(void);
extern  void dmx_cmd_proc(void);
extern	void frame_proc(u8 hz);
extern	void data_conv_spi(u16 num);
extern	void spi_send(void);
extern	void data_conv_mbi6021(u16 piexl);
extern	void dmx_packet_send_ndma(u16 num);
extern  void one_to_eight(u16 aaa,u8 bbb,u16 ccc,u8 *addr);
extern  void mbi6021bgr(void);

void	dis_sd_send(u32 dis_addr);
void	dis_test_send(void);
void	cmd_send(void);

void 	rec_start(void);
void	rec_close(void);
void	ack_analyze(void);

void	read_info_gen(u16 ttt);
void read_info_pro_gen(u16 ttt);
void	write_addr_gen(u16 addr);
void	open_addr_gen(void);
void	start_brightness_gen(void);
void	pwm_config_gen(void);
void 	write_all_brightness_gen(u16 data_num);
void write_color_brightness_gen(u8 *buf);

void 	test_data_gen(void);
void 	data_gen_channel(void);
void 	data_gen_gray(void);
void 	data_gen_c4_gray(void);
void	data_gen_white_gray(void);
void	data_gen_qicai_gray(void);
void	data_gen_white_tianmu_gray(void);
void	data_gen_liushui_white_gray(void);


extern	u8	send_state;
extern	u16	send_length;
extern  u8	send_buf[4110];
extern  uint32_t	dmx_buf_addr;
extern	u8		tube_type,sub_no;
extern 	u8		chanle_num;
extern	u16		dmx_chanle;
extern 	u16		dmx_feq;

#endif
